package scenic.geom;

import java.awt.geom.AffineTransform;

/**
 * This is a convenience class for combining different basic transforms.
 * The class has similar methods then AffineTransform for modifying the, 
 * transformation, with the exception that they return the object so that 
 * multiple transformations can be combined easily. An example usage is: 
 * new TransformBuilder().translateBy(10, 0).scaleBy(5, 5).
 */
@SuppressWarnings("serial")
public class TransformBuilder extends AffineTransform {
	public TransformBuilder() {
	}
	
	public TransformBuilder(AffineTransform t) {
		super(t);
	}
	
	public TransformBuilder translateBy(double tx, double ty) {
		translate(tx, ty);
		return this;
	}

	/**
	 * Similar to the rotate method in AffineTransform class, except that the
	 * angle is given in degrees instead of radians.
	 */
	public TransformBuilder rotateBy(double theta, double x, double y) {
		rotate(Math.toDegrees(theta), x, y);
		return this;
	}

	/**
	 * Similar to the rotate method in AffineTransform class, except that the
	 * angle is given in degrees instead of radians.
	 */
	public TransformBuilder rotateBy(double theta) {
		rotate(Math.toDegrees(theta));
		return this;
	}


	public TransformBuilder scaleBy(double sx, double sy) {
		scale(sx, sy);
		return this;
	}


	public TransformBuilder shearBy(double shx, double shy) {
		shear(shx, shy);
		return this;
	}


	public TransformBuilder transformBy(AffineTransform Tx) {
		concatenate(Tx);
		return this;
	}
}
